class Solution {
public:
    vector<string> letterCasePermutation(string s)
    {
        int n = s.size();
        vector<string> ans;
        string path(n, 0);
        function<void(int)> dfs = [&](int i) {
            if (i == n)
            {
                ans.push_back(path);
                return;
            }
            char e = s[i];
            if (e >= '0' && e <= '9')
            {
                path[i] = e;
                dfs(i + 1);
            }
            else if (e >= 'a' && e <= 'z')
            {
                path[i] = e;
                dfs(i + 1);
                path[i] = e - 32;
                dfs(i + 1);
            }
            else
            {
                path[i] = e;
                dfs(i + 1);
                path[i] = e + 32;
                dfs(i + 1);
            }
            };
        dfs(0);
        return ans;
    }
};